package com.hemerasolutions.v2trainer.model.examination;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.users.Athlete;
import com.hemerasolutions.v2trainer.model.users.User;

@Entity
public class Exam extends BaseModel {

	private static final long serialVersionUID = 1L;

    @Column(length = 60)
	private String name;
    
    @Column
    private int examType;
    
    @Column
    private int category;

    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
	private Date scheduledTo;

    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
	private Date realizedAt;

	@OneToOne 
    @JoinColumn(name="scheduledBy_id")
    private User scheduledBy;    
    
	@OneToOne 
    @JoinColumn(name="realizedBy_id")
    private User realizedBy;    

	@ManyToOne 
	@JoinColumn(name = "athlete_id") 
	private Athlete athlete;
	
	
    public static final int AEROBIC_EVAL = 1;
	
    public static final int ANAMNESE = 2;
    
    public static final int ANTHROPOMETRY = 3;
    
    public static final int BODYSTRUCTURE = 4;
    
    public static final int CRITICAL_POTENCY = 5;
    
    public static final int CRITICAL_VELOCITY = 6;
    
    public static final int ENERGY_REST = 7;
    
    public static final int EVALUATION = 8;
    
    public static final int FLEXIBILITY = 9;
    
    public static final int INCREMENTAL_LACTATE = 10;
    
    public static final int JUMP_TEST = 11;
    
    public static final int LINEAR_REGRESSION = 12;

    public static final int MEDICAL_TEST = 13;

    public static final int POM_TEST = 14;

    public static final int STRENGTH_TEST = 15;

    public static final int WINGATE = 16;

    public static final int CATEGORY_MEDICAL = 1;
    
    public static final int CATEGORY_PSYCHOLOGICAL = 2;
    
    public static final int CATEGORY_PERFORMANCE = 3;
    
    public static final int CATEGORY_PHYSIOLOGICAL = 4;
    

    public Exam() {
		super();
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getName() {
		return name;
	}

	public int getExamType() {
		return examType;
	}

	public Date getScheduledTo() {
		return scheduledTo;
	}

	public Date getRealizedAt() {
		return realizedAt;
	}

	public User getScheduledBy() {
		return scheduledBy;
	}

	public User getRealizedBy() {
		return realizedBy;
	}

	public Athlete getAthlete() {
		return athlete;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setExamType(int examType) {
		this.examType = examType;
	}

	public void setScheduledTo(Date scheduledTo) {
		this.scheduledTo = scheduledTo;
	}

	public void setRealizedAt(Date realizedAt) {
		this.realizedAt = realizedAt;
	}

	public void setScheduledBy(User scheduledBy) {
		this.scheduledBy = scheduledBy;
	}

	public void setRealizedBy(User realizedBy) {
		this.realizedBy = realizedBy;
	}

	public void setAthlete(Athlete athlete) {
		this.athlete = athlete;
	}

	public int getCategory() {
		return category;
	}

	public void setCategory(int category) {
		this.category = category;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((athlete == null) ? 0 : athlete.hashCode());
		result = prime * result + category;
		result = prime * result + examType;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((realizedAt == null) ? 0 : realizedAt.hashCode());
		result = prime * result
				+ ((realizedBy == null) ? 0 : realizedBy.hashCode());
		result = prime * result
				+ ((scheduledBy == null) ? 0 : scheduledBy.hashCode());
		result = prime * result
				+ ((scheduledTo == null) ? 0 : scheduledTo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Exam other = (Exam) obj;
		if (athlete == null) {
			if (other.athlete != null)
				return false;
		} else if (!athlete.equals(other.athlete))
			return false;
		if (category != other.category)
			return false;
		if (examType != other.examType)
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (realizedAt == null) {
			if (other.realizedAt != null)
				return false;
		} else if (!realizedAt.equals(other.realizedAt))
			return false;
		if (realizedBy == null) {
			if (other.realizedBy != null)
				return false;
		} else if (!realizedBy.equals(other.realizedBy))
			return false;
		if (scheduledBy == null) {
			if (other.scheduledBy != null)
				return false;
		} else if (!scheduledBy.equals(other.scheduledBy))
			return false;
		if (scheduledTo == null) {
			if (other.scheduledTo != null)
				return false;
		} else if (!scheduledTo.equals(other.scheduledTo))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Exam [id=" + id + ", name=" + name + ", examType=" + examType
				+ ", category=" + category + ", scheduledTo=" + scheduledTo
				+ ", realizedAt=" + realizedAt + ", scheduledBy=" + scheduledBy
				+ ", realizedBy=" + realizedBy + ", athlete=" + athlete + "]";
	}


	
}
